<html>
<head><meta charset="utf-8"><title>async-fn-in-traits-are-hard · wg-async-foundations · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/index.html">wg-async-foundations</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/async-fn-in-traits-are-hard.html">async-fn-in-traits-are-hard</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="179130483"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/async-fn-in-traits-are-hard/near/179130483" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> centril <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/async-fn-in-traits-are-hard.html#179130483">(Oct 26 2019 at 15:37)</a>:</h4>
<p>( Subject matter: <a href="http://smallcultfollowing.com/babysteps/blog/2019/10/26/async-fn-in-traits-are-hard/" target="_blank" title="http://smallcultfollowing.com/babysteps/blog/2019/10/26/async-fn-in-traits-are-hard/">http://smallcultfollowing.com/babysteps/blog/2019/10/26/async-fn-in-traits-are-hard/</a> )</p>
<blockquote>
<p>Second, writing <code>for&lt;'s&gt; D::GetUser&lt;'s&gt;</code> is kind of grody, we’re obviously going to want more compact syntax (this is really an issue around generic associated types in general).</p>
</blockquote>
<p><code>d: &amp;impl Database&lt;GetUser&lt;'_&gt;: Send&gt;&gt;</code> :P</p>



<a name="179130678"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/async-fn-in-traits-are-hard/near/179130678" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> centril <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/async-fn-in-traits-are-hard.html#179130678">(Oct 26 2019 at 15:42)</a>:</h4>
<blockquote>
<p>Complication #2c. Listing specific associated types reveals implementation details</p>
</blockquote>
<p>It's a semver hazard in either direction (maybe you want to remove the <code>Send</code> bound in the future but then implementors can assume less)</p>



<a name="179130870"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/async-fn-in-traits-are-hard/near/179130870" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> centril <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/async-fn-in-traits-are-hard.html#179130870">(Oct 26 2019 at 15:48)</a>:</h4>
<blockquote>
<p>For example, you could imagine supporting async bounds, so that we might write async Send instead of just Send:</p>
</blockquote>
<p>When I hear "async bound", I assume something related to effect-polymorphism, but this doesn't seem to be that?</p>



<a name="179350262"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/async-fn-in-traits-are-hard/near/179350262" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/async-fn-in-traits-are-hard.html#179350262">(Oct 29 2019 at 17:02)</a>:</h4>
<blockquote>
<p>When I hear "async bound", I assume something related to effect-polymorphism, but this doesn't seem to be that?</p>
</blockquote>
<p>Nope, it would be something else. I probably shouldn't have even added concrete syntax, especially syntax I don't know if I would even like. Maybe something like <code>S::async: Send</code> or <code>S::*: Send</code> .. who knows. The point would be a bound that is applied to the GATs within the trait without naming them individually.</p>



<a name="179350317"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/async-fn-in-traits-are-hard/near/179350317" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/async-fn-in-traits-are-hard.html#179350317">(Oct 29 2019 at 17:03)</a>:</h4>
<blockquote>
<p>It's a semver hazard in either direction (maybe you want to remove the <code>Send</code> bound in the future but then implementors can assume less)</p>
</blockquote>
<p>This is true on traits, but my example was not a trait, but just a function that was listing its where-clauses -- in that context, I don't think it's a semver hazard to get more narrow? but maybe I'm overlooking something</p>



<a name="179350357"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/async-fn-in-traits-are-hard/near/179350357" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/async-fn-in-traits-are-hard.html#179350357">(Oct 29 2019 at 17:03)</a>:</h4>
<p>That said, any kind of "all the things!" feature has a hazard if the trait should grow more items</p>



<a name="179360278"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/async-fn-in-traits-are-hard/near/179360278" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lqd <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/async-fn-in-traits-are-hard.html#179360278">(Oct 29 2019 at 18:36)</a>:</h4>
<blockquote>
<p>I assume something related to effect-polymorphism</p>
</blockquote>
<p>all this reminds me of coeffects as well, since it's kind of a requirement on the context <span aria-label="thinking" class="emoji emoji-1f914" role="img" title="thinking">:thinking:</span></p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>